# -* - coding: UTF-8 -* -
#import sys
#reload(sys)
#sys.setdefaultencoding('utf8')
#将队列分成高中低三个优先级
import string
import time 
from time import sleep
import os
import logging
from task import *
from base_thread import *
#提交任务到FastCGI
class NotifyThread(Thread):  
	def __init__(self,client,notify_center):  
		Thread.__init__(self) 
		self.client = client
		self.notify_center = notify_center	
	def on_run(self):
		#logging.info("Transform Started:"+str(self)) 
		try:
			if not self.notify_center.queue.empty():
				task = self.notify_center.queue.get(timeout=1)# 获取队列 
				try:
					#logging.info('get a message')
					self.client.send(task.client.url,task.data)
				except Exception as e:
					logging.error('NotifyThread.on_run')
					logging.exception(e)
		except:
			pass

